package com.juc.completionService.completionService6;

import java.util.concurrent.CompletionService;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Run1 {

	public static void main(String[] args) throws InterruptedException, ExecutionException {
		Userinfo userinfo = new Userinfo();
		MyRunnable myRunnable = new MyRunnable(userinfo);
		Executor executor = Executors.newCachedThreadPool();
		CompletionService<Userinfo> ceRef = new ExecutorCompletionService<>(executor);
		Future<Userinfo> future = ceRef.submit(myRunnable,userinfo);
		System.out.println(future.get().getUsername() + "      " + future.get().getPassword());
	}
}
